<template>
  <div class="app-container">
    <!-- 高级查询 -->
    <el-form v-show="searchVisible" ref="queryForm" :model="queryParams" :inline="true">
      <el-form-item label=":">
        <el-input v-model="queryParams.itemNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="ref t_po_purchase_order:">
        <el-input v-model="queryParams.purchaseOrderId" size="small" placeholder="请输入ref t_po_purchase_order" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.purchaseOrderNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="ref t_so_sales_order:">
        <el-input v-model="queryParams.salesOrderId" size="small" placeholder="请输入ref t_so_sales_order" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="销售订单编号:">
        <el-input v-model="queryParams.salesOrderNo" size="small" placeholder="请输入销售订单编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="物料编码:">
        <el-input v-model="queryParams.materialNo" size="small" placeholder="请输入物料编码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="物料名称:">
        <el-input v-model="queryParams.materialDesc" size="small" placeholder="请输入物料名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.measUnit" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.cusotmerProductNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.cusotmerProducName" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.orderQuantity" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.diffQuantity" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.salesQuantity" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-date-picker v-model="queryParams.demandDeliveryDate" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择" clearable />
      </el-form-item>
      <el-form-item label=":">
        <el-date-picker v-model="queryParams.arrangedDeliveryDate" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择" clearable />
      </el-form-item>
      <el-form-item label=":">
        <el-date-picker v-model="queryParams.promiseDeliveryDate" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择" clearable />
      </el-form-item>
      <el-form-item label=":">
        <el-date-picker v-model="queryParams.arrangedFreightDate" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择" clearable />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.priceCode" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.balanceCurrenctyNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="单价:">
        <el-input v-model="queryParams.unitPrice" size="small" placeholder="请输入单价" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="总价:">
        <el-input v-model="queryParams.accountSum" size="small" placeholder="请输入总价" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.taxAccount" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.cost" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.discountSum" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.discountRate" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.addOnsDisccountRate" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.orderDiscountSum" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.valueAddedTax" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.containTaxUnitPrice" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.containTaxSum" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.deliveryAddress" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.leadTime" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.noteText" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.supplierId" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-date-picker v-model="queryParams.productExpierDate" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择" clearable />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.productBatchNumber" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.mappedYn" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-date-picker v-model="queryParams.requiredEffectedLength" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择" clearable />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.purchaseLineId" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.remainQuantity" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.customerNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户名称:">
        <el-input v-model="queryParams.customerName" size="small" placeholder="请输入客户名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.warehouseInOrderNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.thisTimeShipped" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="收货人编码:">
        <el-input v-model="queryParams.consigneeId" size="small" placeholder="请输入收货人编码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-date-picker v-model="queryParams.produceDate" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择" clearable />
      </el-form-item>
      <el-form-item label="创建时间:">
        <el-date-picker v-model="queryParams.createDate" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择创建时间" clearable />
      </el-form-item>
      <el-form-item label="更新时间:">
        <el-date-picker v-model="queryParams.updateDate" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择更新时间" clearable />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.priceOfIncludeTax" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.amount" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.materialId" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="到货区域:">
        <el-input v-model="queryParams.destZone" size="small" placeholder="请输入到货区域" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.departZone" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button v-hasPermission="['tms:tPoPurchaseOrderItem:insert']" type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['tms:tPoPurchaseOrderItem:update']" type="success" icon="el-icon-edit" size="mini" :disabled="isSingle" @click="handleEdit">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['tms:tPoPurchaseOrderItem:delete']" type="danger" icon="el-icon-delete" size="mini" :disabled="isMultiple" @click="handleRemove">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['tms:tPoPurchaseOrderItem:export']" type="warning" icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
      </el-col>
      <right-toolbar :show-search.sync="searchVisible" @queryTable="handleQuery" />
    </el-row>

    <!-- 数据列表 -->
    <el-table v-loading="loading" :data="page.records" highlight-current-row @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="" align="center" prop="itemNo" />
      <el-table-column label="ref t_po_purchase_order" align="center" prop="purchaseOrderId" />
      <el-table-column label="" align="center" prop="purchaseOrderNo" />
      <el-table-column label="ref t_so_sales_order" align="center" prop="salesOrderId" />
      <el-table-column label="销售订单编号" align="center" prop="salesOrderNo" />
      <el-table-column label="物料编码" align="center" prop="materialNo" />
      <el-table-column label="物料名称" align="center" prop="materialDesc" />
      <el-table-column label="" align="center" prop="measUnit" />
      <el-table-column label="" align="center" prop="cusotmerProductNo" />
      <el-table-column label="" align="center" prop="cusotmerProducName" />
      <el-table-column label="" align="center" prop="orderQuantity" />
      <el-table-column label="" align="center" prop="diffQuantity" />
      <el-table-column label="" align="center" prop="salesQuantity" />
      <el-table-column label="" align="center" prop="demandDeliveryDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.demandDeliveryDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" prop="arrangedDeliveryDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.arrangedDeliveryDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" prop="promiseDeliveryDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.promiseDeliveryDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" prop="arrangedFreightDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.arrangedFreightDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" prop="priceCode" />
      <el-table-column label="" align="center" prop="balanceCurrenctyNo" />
      <el-table-column label="单价" align="center" prop="unitPrice" />
      <el-table-column label="总价" align="center" prop="accountSum" />
      <el-table-column label="" align="center" prop="taxAccount" />
      <el-table-column label="" align="center" prop="cost" />
      <el-table-column label="" align="center" prop="discountSum" />
      <el-table-column label="" align="center" prop="discountRate" />
      <el-table-column label="" align="center" prop="addOnsDisccountRate" />
      <el-table-column label="" align="center" prop="orderDiscountSum" />
      <el-table-column label="" align="center" prop="valueAddedTax" />
      <el-table-column label="" align="center" prop="containTaxUnitPrice" />
      <el-table-column label="" align="center" prop="containTaxSum" />
      <el-table-column label="" align="center" prop="deliveryType" />
      <el-table-column label="" align="center" prop="deliveryAddress" />
      <el-table-column label="" align="center" prop="leadTime" />
      <el-table-column label="" align="center" prop="noteText" />
      <el-table-column label="" align="center" prop="supplierId" />
      <el-table-column label="" align="center" prop="productExpierDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.productExpierDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" prop="productBatchNumber" />
      <el-table-column label="" align="center" prop="mappedYn" />
      <el-table-column label="" align="center" prop="requiredEffectedLength" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.requiredEffectedLength, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" prop="purchaseLineId" />
      <el-table-column label="" align="center" prop="remainQuantity" />
      <el-table-column label="" align="center" prop="customerNo" />
      <el-table-column label="客户名称" align="center" prop="customerName" />
      <el-table-column label="" align="center" prop="warehouseInOrderNo" />
      <el-table-column label="" align="center" prop="thisTimeShipped" />
      <el-table-column label="收货人编码" align="center" prop="consigneeId" />
      <el-table-column label="" align="center" prop="produceDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.produceDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" prop="status" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="创建时间" align="center" prop="createDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新时间" align="center" prop="updateDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" prop="priceOfIncludeTax" />
      <el-table-column label="" align="center" prop="amount" />
      <el-table-column label="" align="center" prop="materialId" />
      <el-table-column label="到货区域" align="center" prop="destZone" />
      <el-table-column label="" align="center" prop="departZone" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button v-hasPermission="['tms:tPoPurchaseOrderItem:update']" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">修改</el-button>
          <el-button v-hasPermission="['tms:tPoPurchaseOrderItem:delete']" size="mini" type="text" icon="el-icon-delete" @click="handleRemove(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <pagination v-show="page.total>0" :total="page.total" :page.sync="page.current" :limit.sync="page.pageSize" @pagination="handleQuery" />

    <!-- 添加/修改对话框 -->
    <el-dialog :title="tPoPurchaseOrderItemFormDialog.title" :visible.sync="tPoPurchaseOrderItemFormDialog.visible" :close-on-click-modal="false" :before-close="resetTPoPurchaseOrderItemFormDialog" width="500px" append-to-body>
      <el-form ref="tPoPurchaseOrderItemForm" :model="tPoPurchaseOrderItemFormData" :rules="tPoPurchaseOrderItemFormRules" label-width="80px">
        <el-form-item label="" prop="itemNo">
          <el-input v-model="tPoPurchaseOrderItemFormData.itemNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="ref t_po_purchase_order" prop="purchaseOrderId">
          <el-input v-model="tPoPurchaseOrderItemFormData.purchaseOrderId" placeholder="请输入ref t_po_purchase_order" />
        </el-form-item>
        <el-form-item label="" prop="purchaseOrderNo">
          <el-input v-model="tPoPurchaseOrderItemFormData.purchaseOrderNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="ref t_so_sales_order" prop="salesOrderId">
          <el-input v-model="tPoPurchaseOrderItemFormData.salesOrderId" placeholder="请输入ref t_so_sales_order" />
        </el-form-item>
        <el-form-item label="销售订单编号" prop="salesOrderNo">
          <el-input v-model="tPoPurchaseOrderItemFormData.salesOrderNo" placeholder="请输入销售订单编号" />
        </el-form-item>
        <el-form-item label="物料编码" prop="materialNo">
          <el-input v-model="tPoPurchaseOrderItemFormData.materialNo" placeholder="请输入物料编码" />
        </el-form-item>
        <el-form-item label="物料名称" prop="materialDesc">
          <el-input v-model="tPoPurchaseOrderItemFormData.materialDesc" placeholder="请输入物料名称" />
        </el-form-item>
        <el-form-item label="" prop="measUnit">
          <el-input v-model="tPoPurchaseOrderItemFormData.measUnit" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="cusotmerProductNo">
          <el-input v-model="tPoPurchaseOrderItemFormData.cusotmerProductNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="cusotmerProducName">
          <el-input v-model="tPoPurchaseOrderItemFormData.cusotmerProducName" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="orderQuantity">
          <el-input v-model="tPoPurchaseOrderItemFormData.orderQuantity" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="diffQuantity">
          <el-input v-model="tPoPurchaseOrderItemFormData.diffQuantity" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="salesQuantity">
          <el-input v-model="tPoPurchaseOrderItemFormData.salesQuantity" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="demandDeliveryDate">
          <el-date-picker v-model="tPoPurchaseOrderItemFormData.demandDeliveryDate" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择" clearable />
        </el-form-item>
        <el-form-item label="" prop="arrangedDeliveryDate">
          <el-date-picker v-model="tPoPurchaseOrderItemFormData.arrangedDeliveryDate" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择" clearable />
        </el-form-item>
        <el-form-item label="" prop="promiseDeliveryDate">
          <el-date-picker v-model="tPoPurchaseOrderItemFormData.promiseDeliveryDate" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择" clearable />
        </el-form-item>
        <el-form-item label="" prop="arrangedFreightDate">
          <el-date-picker v-model="tPoPurchaseOrderItemFormData.arrangedFreightDate" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择" clearable />
        </el-form-item>
        <el-form-item label="" prop="priceCode">
          <el-input v-model="tPoPurchaseOrderItemFormData.priceCode" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="balanceCurrenctyNo">
          <el-input v-model="tPoPurchaseOrderItemFormData.balanceCurrenctyNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="单价" prop="unitPrice">
          <el-input v-model="tPoPurchaseOrderItemFormData.unitPrice" placeholder="请输入单价" />
        </el-form-item>
        <el-form-item label="总价" prop="accountSum">
          <el-input v-model="tPoPurchaseOrderItemFormData.accountSum" placeholder="请输入总价" />
        </el-form-item>
        <el-form-item label="" prop="taxAccount">
          <el-input v-model="tPoPurchaseOrderItemFormData.taxAccount" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="cost">
          <el-input v-model="tPoPurchaseOrderItemFormData.cost" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="discountSum">
          <el-input v-model="tPoPurchaseOrderItemFormData.discountSum" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="discountRate">
          <el-input v-model="tPoPurchaseOrderItemFormData.discountRate" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="addOnsDisccountRate">
          <el-input v-model="tPoPurchaseOrderItemFormData.addOnsDisccountRate" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="orderDiscountSum">
          <el-input v-model="tPoPurchaseOrderItemFormData.orderDiscountSum" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="valueAddedTax">
          <el-input v-model="tPoPurchaseOrderItemFormData.valueAddedTax" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="containTaxUnitPrice">
          <el-input v-model="tPoPurchaseOrderItemFormData.containTaxUnitPrice" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="containTaxSum">
          <el-input v-model="tPoPurchaseOrderItemFormData.containTaxSum" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="deliveryAddress">
          <el-input v-model="tPoPurchaseOrderItemFormData.deliveryAddress" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="leadTime">
          <el-input v-model="tPoPurchaseOrderItemFormData.leadTime" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="noteText">
          <el-input v-model="tPoPurchaseOrderItemFormData.noteText" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="supplierId">
          <el-input v-model="tPoPurchaseOrderItemFormData.supplierId" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="productExpierDate">
          <el-date-picker v-model="tPoPurchaseOrderItemFormData.productExpierDate" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择" clearable />
        </el-form-item>
        <el-form-item label="" prop="productBatchNumber">
          <el-input v-model="tPoPurchaseOrderItemFormData.productBatchNumber" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="mappedYn">
          <el-input v-model="tPoPurchaseOrderItemFormData.mappedYn" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="requiredEffectedLength">
          <el-date-picker v-model="tPoPurchaseOrderItemFormData.requiredEffectedLength" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择" clearable />
        </el-form-item>
        <el-form-item label="" prop="purchaseLineId">
          <el-input v-model="tPoPurchaseOrderItemFormData.purchaseLineId" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="remainQuantity">
          <el-input v-model="tPoPurchaseOrderItemFormData.remainQuantity" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="customerNo">
          <el-input v-model="tPoPurchaseOrderItemFormData.customerNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="客户名称" prop="customerName">
          <el-input v-model="tPoPurchaseOrderItemFormData.customerName" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="" prop="warehouseInOrderNo">
          <el-input v-model="tPoPurchaseOrderItemFormData.warehouseInOrderNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="thisTimeShipped">
          <el-input v-model="tPoPurchaseOrderItemFormData.thisTimeShipped" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="收货人编码" prop="consigneeId">
          <el-input v-model="tPoPurchaseOrderItemFormData.consigneeId" placeholder="请输入收货人编码" />
        </el-form-item>
        <el-form-item label="" prop="produceDate">
          <el-date-picker v-model="tPoPurchaseOrderItemFormData.produceDate" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择" clearable />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="tPoPurchaseOrderItemFormData.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="创建时间" prop="createDate">
          <el-date-picker v-model="tPoPurchaseOrderItemFormData.createDate" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择创建时间" clearable />
        </el-form-item>
        <el-form-item label="更新时间" prop="updateDate">
          <el-date-picker v-model="tPoPurchaseOrderItemFormData.updateDate" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择更新时间" clearable />
        </el-form-item>
        <el-form-item label="" prop="priceOfIncludeTax">
          <el-input v-model="tPoPurchaseOrderItemFormData.priceOfIncludeTax" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="amount">
          <el-input v-model="tPoPurchaseOrderItemFormData.amount" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="materialId">
          <el-input v-model="tPoPurchaseOrderItemFormData.materialId" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="到货区域" prop="destZone">
          <el-input v-model="tPoPurchaseOrderItemFormData.destZone" placeholder="请输入到货区域" />
        </el-form-item>
        <el-form-item label="" prop="departZone">
          <el-input v-model="tPoPurchaseOrderItemFormData.departZone" placeholder="请输入" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirmTPoPurchaseOrderItemFormDialog">确 定</el-button>
        <el-button @click="resetTPoPurchaseOrderItemFormDialog">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import TPoPurchaseOrderItemApi from '@/api/tms/TPoPurchaseOrderItemApi'

const defaultTPoPurchaseOrderItemFormData = {
  itemNo: null,  purchaseOrderId: null,  purchaseOrderNo: null,  salesOrderId: null,  salesOrderNo: null,  materialNo: null,  materialDesc: null,  measUnit: null,  cusotmerProductNo: null,  cusotmerProducName: null,  orderQuantity: null,  diffQuantity: null,  salesQuantity: null,  demandDeliveryDate: null,  arrangedDeliveryDate: null,  promiseDeliveryDate: null,  arrangedFreightDate: null,  priceCode: null,  balanceCurrenctyNo: null,  unitPrice: null,  accountSum: null,  taxAccount: null,  cost: null,  discountSum: null,  discountRate: null,  addOnsDisccountRate: null,  orderDiscountSum: null,  valueAddedTax: null,  containTaxUnitPrice: null,  containTaxSum: null,  deliveryType: null,  deliveryAddress: null,  leadTime: null,  noteText: null,  supplierId: null,  productExpierDate: null,  productBatchNumber: null,  mappedYn: null,  requiredEffectedLength: null,  purchaseLineId: null,  remainQuantity: null,  customerNo: null,  customerName: null,  warehouseInOrderNo: null,  thisTimeShipped: null,  consigneeId: null,  produceDate: null,  status: '0',  createDate: null,  updateDate: null,  priceOfIncludeTax: null,  amount: null,  materialId: null,  destZone: null,  departZone: null}
export default {
  name: 'TPoPurchaseOrderItemList',
  data() {
    return {
      options: {
        sysYnTypeOptions: this.$constant.sysYnTypeOptions
      },
      queryParams: {
        itemNo: null,
        purchaseOrderId: null,
        purchaseOrderNo: null,
        salesOrderId: null,
        salesOrderNo: null,
        materialNo: null,
        materialDesc: null,
        measUnit: null,
        cusotmerProductNo: null,
        cusotmerProducName: null,
        orderQuantity: null,
        diffQuantity: null,
        salesQuantity: null,
        demandDeliveryDate: null,
        arrangedDeliveryDate: null,
        promiseDeliveryDate: null,
        arrangedFreightDate: null,
        priceCode: null,
        balanceCurrenctyNo: null,
        unitPrice: null,
        accountSum: null,
        taxAccount: null,
        cost: null,
        discountSum: null,
        discountRate: null,
        addOnsDisccountRate: null,
        orderDiscountSum: null,
        valueAddedTax: null,
        containTaxUnitPrice: null,
        containTaxSum: null,
        deliveryType: null,
        deliveryAddress: null,
        leadTime: null,
        noteText: null,
        supplierId: null,
        productExpierDate: null,
        productBatchNumber: null,
        mappedYn: null,
        requiredEffectedLength: null,
        purchaseLineId: null,
        remainQuantity: null,
        customerNo: null,
        customerName: null,
        warehouseInOrderNo: null,
        thisTimeShipped: null,
        consigneeId: null,
        produceDate: null,
        status: null,
        createDate: null,
        updateDate: null,
        priceOfIncludeTax: null,
        amount: null,
        materialId: null,
        destZone: null,
        departZone: null,
        isValid: this.$constant.Y
      },
      page: {
        current: 1,
        pageSize: 10,
        total: 0,
        records: []
      },
      tPoPurchaseOrderItemFormDialog: {
        title: '',
        visible: false
      },
      tPoPurchaseOrderItemFormData: Object.assign({}, defaultTPoPurchaseOrderItemFormData),
      tPoPurchaseOrderItemFormRules: {
        createDate: [{ required: true, message: '创建时间不能为空', trigger: 'blur' }],
        updateDate: [{ required: true, message: '更新时间不能为空', trigger: 'blur' }],
      },
      loading: true,
      searchVisible: true,
      multipleSelection: [],
      isSingle: true,
      isMultiple: true
    }
  },
  created() {
    this.handleQuery()
    this.loadOptions()
  },
  methods: {
    loadOptions() {
    },
    handleAdd() {
      this.openTPoPurchaseOrderItemFormDialog()
    },
    handleRemove(row) {
      const ids = row.id || this.multipleSelection.map(item => item.id)
      this.$confirm('是否确认删除数据?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return TPoPurchaseOrderItemApi.remove(ids)
      }).then(() => {
        this.handleQuery()
        this.$message.success('删除成功')
      })
    },
    handleEdit(row) {
      const id = row.id || this.multipleSelection.map(item => item.id)[0]
      this.openTPoPurchaseOrderItemFormDialog(id)
    },
    handleQuery() {
      this.loading = true
      TPoPurchaseOrderItemApi.page(this.queryParams, this.page).then(response => {
        this.page.records = response.data.records
        this.page.total = response.data.total
        this.loading = false
      }, () => {
        this.loading = false
      })
    },
    handleExport() {
      this.$confirm('是否确认导出数据?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return TPoPurchaseOrderItemApi.exportData(this.queryParams)
      }).then(response => {
        this.$common.download(response.msg)
      })
    },
    openTPoPurchaseOrderItemFormDialog(id) {
      this.tPoPurchaseOrderItemFormDialog.visible = true
      if (id) {
        this.tPoPurchaseOrderItemFormDialog.title = '运输计划明细-修改'
        TPoPurchaseOrderItemApi.get(id).then(response => {
          this.tPoPurchaseOrderItemFormData = {
            ...this.tPoPurchaseOrderItemFormData,
            ...response.data
          }
        })
      } else {
        this.tPoPurchaseOrderItemFormDialog.title = '运输计划明细-添加'
      }
    },
    confirmTPoPurchaseOrderItemFormDialog() {
      this.$refs['tPoPurchaseOrderItemForm'].validate(valid => {
        if (valid) {
          if (this.tPoPurchaseOrderItemFormData.id) {
            TPoPurchaseOrderItemApi.edit(this.tPoPurchaseOrderItemFormData).then(response => {
              this.$message.success('修改成功')
              this.resetTPoPurchaseOrderItemFormDialog()
              this.handleQuery()
            })
          } else {
            TPoPurchaseOrderItemApi.add(this.tPoPurchaseOrderItemFormData).then(response => {
              this.$message.success('添加成功')
              this.resetTPoPurchaseOrderItemFormDialog()
              this.handleQuery()
            })
          }
        }
      })
    },
    resetTPoPurchaseOrderItemFormDialog() {
      this.tPoPurchaseOrderItemFormDialog = {
        title: '',
        visible: false
      }
      this.tPoPurchaseOrderItemFormData = Object.assign({}, defaultTPoPurchaseOrderItemFormData)
      this.resetForm('tPoPurchaseOrderItemForm')
    },
    handleSelectionChange(selection) {
      this.multipleSelection = selection
      this.isSingle = selection.length !== 1
      this.isMultiple = !selection.length
    },
    resetQuery() {
      this.page.current = 1
      this.resetForm('queryForm')
      this.handleQuery()
    }
  }
}
</script>
